Implement file upload with progress bar and Ajax File Upload Based on ajax technology
1. Overview
In actual Web development or website development, file
Based on my knowledge, all the File Upload control which based onRfc1867(Form-based file upload in HTML. (http://www.ietf.org/rfc/rfc1867.txt) need a full PostBack, and cannot work in an updatepanel.
There are using way to make a "ajax"
:
Ajaxcontroltooki:This directory contains all of the Ajax Control ToolkitSource codeAnd the corresponding Visual StudioProject file. You can view the source code to learn how to compile custom ASP. NET Ajax controls, perform secondary development based on these controls, or improve these controls.
Binaries: Auxiliary. Net assembly for other projects in
Type one: Use the Targer property of the From form + hidden iframe to achieve similar results, supporting the submission of complex forms containing files and common dataWay two: Use jquery's. Ajax (..), which supports the submission of regular forms, but does not support complex forms containing files; Ajax ({...}), which supports the submission of regular forms, but does not support complex forms containi
Ajax asynchronous Upload Based on the bootstrap upload plug-in fileinput (supports multi-File Upload preview and drag/drop), fileinputajax
First, you need to import some js and css files.
Html code
Js Code
$ ("# File-1 "). filei
Ajax forms asynchronously upload file instance Code (including file fields), ajax uploads files
1. Cause
When creating a front-end page, you need to call the Post request of WebAPI to send some fields and files (equivalent to sending the form asynchronously through
User uploads in the project is always indispensable, the following is the main list of the form upload and Ajax upload! Note: Context. Request.Files is not suitable for large files to operate, the following list is mainly for small file upload processing! This article is mai
Javascript uses uploadify for Multifile upload and ajax for File Upload
Using uploadify to upload files allows the client to determine the file size, control the File
Today, when the project ran into a problem: before a colleague left to do a site, there is a upload product detailed picture of the function, was completed, but due to the late program changes and changes in the level of the programmer is also uneven, resulting in a lot of program bugs, due to the use of a framework, Finally did not find the documentation, and then I re-wrote a combination of Ajax
Technical points: 1) H5 formData (),2)XMLHttpRequest ()Using FormData 对象, We can simulate a series of form controls using JS with some key-value pairs, and we can use the XMLHttpRequest Send () method to submit the form asynchronously. The biggest advantage of using FormData compared to normal Ajax is that we can upload binary files asynchronously.Case:$INPUTOBJ. Change (function(){ varFile = $ ( This) [
Html Js function Getfiletype (FilePath) {Gets the suffix name of the filevar startIndex = Filepath.lastindexof (".");if (startIndex! =-1)Return filepath.substring (startindex+1, filepath.length);else return "";}function UploadFile (obj, type) {var FilePath = $ ("#excel_input"). Val ();if (""! = FilePath) {var fileType = Getfiletype (FilePath);Determine if the uploaded attachment is a Word file and an Excel fileif ("Doc"!=filetype "docx"!=filetype "
JS does not have permission to read local files, so cannot upload files but
There are several ways
1 iframe Camouflage Jquery-uploaded-file
2 swf Plugin (this does not speak, is a separate software
3 HTML5
IFRAME simulation Ajax File Upload effect1 Capturing form submission
Transfer
Ajax upload (XMLHTTP File Upload exceeds the size limit)
This page is accessing data from other domains. Can you do this?
Upload. aspResponse. contenttype = "text/XML"Response. charset = "UTF-8"Dim xmldomDim root, PICSet xmldom = server. Createobject ("Microsoft.
If the user is prompted to upload the success, then if the user upload a larger file, then the half are not reflected, then the user is likely to refresh or close the never ...So it will have a certain impact on our servers, so we can improve the user experience in this area, such as to do the same as we often see the progress barDOCTYPE HTML>HTMLLang= "en">Head>
Ajax file upload, ajax
Don't talk about anything, just go to the code!
Js Code
Function UpladFile () {var fileObj = document. getElementById ("file "). files [0]; // js obtains the file object var FileController = "/
: This article describes how to simulate ajax file upload using ajax-iframe. For more information about PHP tutorials, see. Js does not have permission to read local files. so files cannot be uploaded
There are several methods
1 iframe disguise jquery-uploaded-file
2. swf pl
In the actual development in fact, we can give users some hints, such as upload success or upload failure, nonsense said, walk code:DOCTYPE HTML>HTMLLang= "en">Head> MetaCharSet= "UTF-8"> title>Documenttitle> Scriptsrc= "Jq183.js">Script> Script> functionAjaxup () {varifname= ' up'+Math.random (); $(""+ifname+"' height= ' 0 ' width= ' 0 ' frameborder= ' 0 ' >"). AppendTo ($ ('Body')); $('
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.